
# 写入文件
path = '/Users/xjf/Documents/Python_work/text_files/'

filename = 'programming.txt'


with open(path+filename, 'w') as file_object:  # w 写入
    file_object.write('I love programming!\n')
    file_object.write('I love creating new game.\n')


# 附加到文件中
with open(path+filename, 'a') as file_object: # a 写入
    file_object.write("i love too!")
